<!DOCTYPE html>
<html lang="en">
<link>
    <meta charset="UTF-8">
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="./modal.css"/>
    <style>
        .modal-mask {
            position: fixed;
            z-index: 9998;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, .5);
            display: table;
            transition: opacity .3s ease;
        }

        .modal-wrapper {
            display: table-cell;
            vertical-align: middle;
        }

        .modal-container {
            width: 300px;
            margin: 0px auto;
            padding: 20px 30px;
            background-color: #fff;
            border-radius: 2px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
            transition: all .3s ease;
            font-family: Helvetica, Arial, sans-serif;
        }

        .modal-header h3 {
            margin-top: 0;
            color: #42b983;
        }

        .modal-body {
            margin: 20px 0;
        }

        .modal-default-button {
            float: right;
        }

        .modal-enter {
            opacity: 0;
        }

        .modal-leave-to {
            opacity: 0;
        }

        .modal-enter .modal-container,
        .modal-leave-to .modal-container {
            -webkit-transform: scale(1.1);
            transform: scale(1.1);
        }



    </style>
    
    <script>
        function clickMe() {
//            var elements = document.getElementsByClassName('modal-mask');
//            if(elements){
//                var  element = elements[0];
//                console.log( 'element: ' + element.style.display );
//                if(element.style.display=="none"){
//                    element.style.display = '';
//                }else{
//                    element.style.display="none";
//                }
//            }


            var mask = document.getElementById("mask");//获取遮罩层
            var loginBox = document.getElementById("loginBox");//获取窗体

            mask.style.display="";
            loginBox.style.display="";
//            loginBox.center(350,250);//设置船体居中
//
//
//            //浏览器窗口改变时依然居中
//            $().resize(function(){
//                loginBox.center(350,250);
//
//            });
//            //默认弹窗隐藏，点击登录按钮时显示弹窗
//            $().getClass("login").click(function() {
//                /* Act on the event */
//                loginBox.show();
//                mask.show();
//            });
//            //点击关闭按钮时隐藏弹窗
//            $().getClass("close").click(function() {//点击窗体关闭按钮，
//                /* Act on the event */
//                loginBox.hide();
//                mask.hide();
//            });
//



        }
    </script>
</head>
<body>


<div>
    <!-- 弹窗组件 -->
    <div id="mask"></div>
    <div id="loginBox">
        <!--img src="images/close.png" alt="" class="close">-->
        <h2>网站登录</h2>
        <div class="user">账 号：<input type="text"  name="username" class="text" /></div>
        <div class="pass">密 码：<input type="password" name="password" class="text" /></div>
        <div class="button"><input type="button" class="submit" />提交</div>
        <div class="other">注册新用户 | 忘记密码？</div>
    </div>

</div>




<div class="modal-mask">
    <div class="modal-wrapper">
        <div class="modal-container">
            <div class="modal-header">
                <div name="header">
                    标题
                </div>
            </div>

            <div class="modal-body">
                <div name="body">
                    文本
                </div>
            </div>

            <div class="modal-footer">
                <div name="footer">
                    default footer
                    <button  onclick="clickMe()" class="modal-default-button" @click="$emit('close')">
                        OK
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>

<button onclick="clickMe()">测试1</button>

<script>
    var elements = document.getElementsByClassName('modal-mask');
    if(elements) {
        var element = elements[0];
        element.style.display="none";
    }







</script>




</body>
</html>